/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package Grafik;

import java.util.Arrays;

/**
 *
 * @author Charles Thillemann Hemmingsen s122801
 */
public class LoginPanel extends javax.swing.JPanel
{

    public MainSkærm ejer;

    public void setEjer(MainSkærm ejer)
    {
        this.ejer = ejer;
    }

    /**
     * Creates new form LoginPanel
     */
    public LoginPanel()
    {
        initComponents();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents()
    {

        LoginPasswordField = new javax.swing.JPasswordField();
        LoginButton = new javax.swing.JButton();
        forkertKodeordError = new javax.swing.JLabel();

        setLayout(null);

        LoginPasswordField.setText("jPasswordField1");
        add(LoginPasswordField);
        LoginPasswordField.setBounds(173, 273, 131, 30);

        LoginButton.setText("Log In");
        LoginButton.addActionListener(new java.awt.event.ActionListener()
        {
            public void actionPerformed(java.awt.event.ActionEvent evt)
            {
                LoginButtonActionPerformed(evt);
            }
        });
        add(LoginButton);
        LoginButton.setBounds(173, 340, 131, 64);

        forkertKodeordError.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        forkertKodeordError.setForeground(new java.awt.Color(255, 0, 51));
        forkertKodeordError.setText("Forkert koderord");
        add(forkertKodeordError);
        forkertKodeordError.setBounds(173, 215, 131, 22);
    }// </editor-fold>//GEN-END:initComponents

    private void LoginButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_LoginButtonActionPerformed
        if (Arrays.equals(LoginPasswordField.getPassword(), ejer.kodeord))
        {
            // Rykker hovedpanel til øverste lag
            ejer.hovedPanel.setVisible(true);
            ejer.rykForest(ejer.hovedPanel);

            // Gør opsætning usynlig
            this.setVisible(false);
        } else
        {
            forkertKodeordError.setVisible(true);
        }
    }//GEN-LAST:event_LoginButtonActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton LoginButton;
    public javax.swing.JPasswordField LoginPasswordField;
    public javax.swing.JLabel forkertKodeordError;
    // End of variables declaration//GEN-END:variables
}
